package com.gollum.web.controller.monitor;

import com.alibaba.fastjson2.JSONObject;
import com.gollum.common.domain.response.RestResponse;
import com.gollum.common.utils.MessageUtils;
import com.gollum.common.web.controller.BaseController;
import com.gollum.system.domain.request.SysOnlineRequest;
import com.gollum.system.service.SysOnlineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 在线用户
 *
 * @author Herther
 * @createTime 2022年09月23日 22:24:00
 * @since 1.0.0
 */
@Api(tags = "系统监控中心-在线用户")
@RestController
@RequestMapping("/online")
public class SysOnlineController extends BaseController {

    @Autowired
    private SysOnlineService sysOnlineService;



    @PostMapping("/list")
    @ApiOperation(value = "分页查询在线用户")
    public RestResponse listPage(@RequestBody JSONObject jsonObject) {
        buildPageQuery(jsonObject);
        return RestResponse.success(sysOnlineService.listPage(this.toJavaObjectParams(SysOnlineRequest.class, jsonObject)));
    }

    @GetMapping("force/{sessionIds}")
    @ApiOperation(value= "强制退出登录")
    public RestResponse forceLogout(@PathVariable("sessionIds") String[] sessionIds){
        sysOnlineService.forceLogout(sessionIds);
        return RestResponse.success().setMsg(MessageUtils.getMsg("resp.handle_success"));
    }


}
